﻿using System;

namespace diantou.web.enterprise
{
    /// <summary>
    /// 编程题预览
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPool = true, IsPage = false)]
    partial class problemPreview : onlineJudge.problemView<problemPreview>
    {
        /// <summary>
        /// 题目计数是否有效
        /// </summary>
        private byte isQuestionCounter;
        /// <summary>
        /// 题目计数
        /// </summary>
        private diantou.examDataAccess.examQuestion.counter questionCounter;
        /// <summary>
        /// 题目计数
        /// </summary>
        internal diantou.examDataAccess.examQuestion.counter QuestionCounter
        {
            get
            {
                if (isQuestionCounter == 0)
                {
                    questionCounter = diantou.examDataAccess.tcpCall.examQuestion.getCounter(currentUserId);
                    isQuestionCounter = 1;
                }
                return questionCounter;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="problemId"></param>
        /// <returns></returns>
        protected override bool loadView(int problemId)
        {
            if ((currentUser.Permission & dataModel.user.permission.ExamEditor) != 0
                && (problem = diantou.examDataAccess.tcpCall.examProblem.getPreview(problemId, currentUserId)) != null)
            {
                //description = diantou.dataAccess.tcpCall.problem.GetDescription(problem.Id);
                return true;
            }
            AjaxResponse(webConfig.NotFound404);
            return false;
        }
        /// <summary>
        /// 
        /// </summary>
        protected override void clear()
        {
            base.clear();
            isQuestionCounter = 0;
        }
    }
}
